package server.content.skills.wc;

public class GlobalTree {

	private final int respawnTime, id, x, y, logs;
	private int timer = -1, currLogs = -1;
	private boolean isDead;

	public GlobalTree(final int id, final int logs, final int x, final int y,
			final int respawnTime) {
		this.id = id;
		this.logs = logs;
		currLogs = this.logs;
		this.x = x;
		this.y = y;
		this.respawnTime = respawnTime;
		isDead = false;
	}

	public void processGlobalTree() {
		if (getCurrLogs() <= 0 && !isDead()) {
			setCurrLogs(0);
			// draw stump at x & y
			timer = respawnTime;
			setDead(true);
		} else if (getCurrLogs() <= 0 && isDead()) {
			if (timer > 0) {
				timer--;
			} else if (timer == 0) {
				// draw tree at x & y
				setCurrLogs(logs);
				setDead(false);
				timer = -1;
				MiracleWC.undeads.add(this);
			}
		}
	}

	public int getId() {
		return id;
	}
	
	public int getLogs() {
		return logs;
	}

	public int getCurrLogs() {
		return currLogs;
	}

	public void setCurrLogs(final int logs) {
		this.currLogs = logs;
	}

	public int getX() {
		return x;
	}

	public int getY() {
		return y;
	}

	public void setDead(final boolean isDead) {
		this.isDead = isDead;
	}

	public boolean isDead() {
		return isDead;
	}

}
